<template>
	<MainContent>
		<template v-slot:title>
			<span class="title">
				<i class="el-icon-s-data"></i>
				<span>&nbsp;字典数据({{ code }})</span>
			</span>
		</template>
		<el-table :data="dictionaries" size="mini" stripe>
			<el-table-column type="selection" width="55" align="center"></el-table-column>
			<el-table-column prop="key" label="键"></el-table-column>
			<el-table-column prop="value" label="值"></el-table-column>
			<el-table-column prop="category" label="分类"></el-table-column>
			<el-table-column prop="inner" label="系统内置"></el-table-column>
			<el-table-column prop="createTime" label="创建时间"></el-table-column>
			<el-table-column prop="updateTime" label="更新时间"></el-table-column>
			<el-table-column prop="remarks" label="备注"></el-table-column>
			<el-table-column label="操作">
				<template>
					<el-button size="smallest">编辑</el-button>
					<el-button size="smallest" type="danger">删除</el-button>
				</template>
			</el-table-column>
		</el-table>
	</MainContent>
</template>

<script>
import MainContent from "@/components/common/MainContent";
export default {
	name: "Dictionary",
	components: { MainContent },
	data() {
		return {
			code: "",
			dictionaries: []
		}
	},
	methods: {
		getDictionary(code) {
			this.axios.post("/sys/dict/getDictionaries", null, {
				params: { categoryCode: code }
			})
				.then(response => {
					if (response.status === 200) {
						this.dictionaries = response.data
					}
				})
		}
	},
	beforeRouteEnter(to, from, next) {
		console.log("beforeRouteEnter")
		let code = to.query.code
		next(vm => {
			vm.code = code
			vm.getDictionary(code)
		})
	},
	beforeRouteUpdate() {
		console.log("beforeRouteUpdate")
	}
}
</script>

<style scoped>

</style>
